package com.atguigu.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * create by undeRdoG on  2021-06-08  14:26
  * 凡心所向，素履以往，生如逆旅，一苇以航。
  */
object Spark22_RDD_Operator_Transform {

  def main(args: Array[String]): Unit = {

    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Operator")
    val sc = new SparkContext(sparkConf)

    // TODO 算子 - (Key - Value类型)

    val rdd1 = sc.makeRDD(List(("a", 1), ("b", 2), ("c", 3)))

    val rdd2 = sc.makeRDD(List(("a", 4), ("b", 5)))

    val leftOutJoinRDD: RDD[(String, (Int, Option[Int]))] = rdd1.leftOuterJoin(rdd2)


    /*
    *
    *(a,(1,Some(4)))
    *(b,(2,Some(5)))
    *(c,(3,None))
    * */
    leftOutJoinRDD.collect().foreach(println)

  }
}